/**
 * Copyright (c)  2018-2028 DHCC, Inc.
 * All rights reserved.
 * <p>
 * This software is the confidential and proprietary information of DHCC,
 * Inc. ("Confidential Information"). You shall not
 * disclose such Confidential Information and shall use it only in
 * accordance with the terms of the license agreement you entered into with DHCC.
 */
package cn.com.lookang.packager;

import freemarker.template.TemplateMethodModelEx;
import freemarker.template.TemplateModelException;

import java.util.HashMap;
import java.util.List;

/**
 * 自定义字典值转换
 *  dicConvert(#dicType,DicValue)
 * @author: liulekang
 * @Date: 2019/7/16 
 */
public class DicConvert implements TemplateMethodModelEx {
    private static HashMap<String,HashMap<String, String>> dicMap = new HashMap<String, HashMap<String, String>>();
    private static HashMap<String,String> bequeryIdtypeDicMap = new HashMap<String, String>();

    static {
        bequeryIdtypeDicMap.put("1","身份证");
        bequeryIdtypeDicMap.put("10","户口本");
        dicMap.put("bequeryIdtype",bequeryIdtypeDicMap);
    }

    @Override
    public Object exec(List arguments) throws TemplateModelException {
        String result = "";
        if (arguments != null || arguments.size()>1) {
            String dicType = arguments.get(0).toString();
            String dicCode = arguments.get(1).toString();
            HashMap<String,String> hashMap = dicMap.get(dicType);
            result = hashMap.get(dicCode);
        }
        return result;
    }
}
